package com.iqik.rabbit.listen;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class OrderListener {

    @RabbitListener(queues = "queue.order", ackMode = "MANUAL")
    public void onMessage(String order, Channel channel, Message message) throws IOException {
        System.out.println("订单存储:  " + order);
        System.out.println("...");
        System.out.println("手动 ack MQ");
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }
}
